﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Spring.Context.Support;
using Spring.Context;
using Service.Interface;

namespace SendMessageService
{
    public partial class SendMessageService : Form
    {
        public SendMessageService()
        {
            InitializeComponent();
        }

        System.Timers.Timer t;

        //运行按钮
        private void btnRun_Click(object sender, EventArgs e)
        {
            t = new System.Timers.Timer(60000);
            t.Elapsed +=new System.Timers.ElapsedEventHandler(t_Elapsed);
            t.AutoReset = true;//还是一直执行
            t.Enabled = true;//执行事件
        }

        void t_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            localhost.AutoSendMsgService service = new localhost.AutoSendMsgService();//调用WebService，发送邮件和短信
            service.AutoSendMessage();
        }

        //停止按钮
        private void btnStop_Click(object sender, EventArgs e)
        {
            if (t != null)
            {
                t.Enabled = false;
            }
        }
    }
}
